#!/bin/bash

## DEBUGGING
DEBUG=${DEBUG:-false}

## CORE
NEXTCLOUD_CONFIG_DIR=${NEXTCLOUD_CONFIG_DIR:-$NEXTCLOUD_DATA_DIR/config}
NEXTCLOUD_OCDATA_DIR=${NEXTCLOUD_OCDATA_DIR:-$NEXTCLOUD_DATA_DIR/ocdata}
NEXTCLOUD_BACKUPS_DIR=${NEXTCLOUD_BACKUPS_DIR:-$NEXTCLOUD_DATA_DIR/backups}

NEXTCLOUD_ADMIN_USER=${NEXTCLOUD_ADMIN_USER:-admin}
NEXTCLOUD_ADMIN_PASSWORD=${NEXTCLOUD_ADMIN_PASSWORD:-password}

NEXTCLOUD_URL=${NEXTCLOUD_URL:-}
NEXTCLOUD_URL=${NEXTCLOUD_URL:-$PHP_FPM_ENV_NEXTCLOUD_URL}
NEXTCLOUD_URL=${NEXTCLOUD_URL:-http://localhost}

# credits: http://stackoverflow.com/a/2506635/4799938
NEXTCLOUD_FQDN=$(sed -e "s/\([^/]*\)\:\/\/\([^@]*@\)\?\([^:/]*\).*/\3/" <<< ${NEXTCLOUD_URL})
if [[ $(sed -e "s/\([^/]*\)\:\/\/\([^@]*@\)\?\([^:/]*\).*/\1/" <<< ${NEXTCLOUD_URL}) == https ]]; then
  NEXTCLOUD_HTTPS=${NEXTCLOUD_HTTPS:-on}
else
  NEXTCLOUD_HTTPS=${NEXTCLOUD_HTTPS:-off}
fi

NEXTCLOUD_UPLOAD_MAX_FILESIZE=${NEXTCLOUD_UPLOAD_MAX_FILESIZE:-4G}
NEXTCLOUD_MAX_FILE_UPLOADS=${NEXTCLOUD_MAX_FILE_UPLOADS:-20}

## BACKUPS
NEXTCLOUD_BACKUPS_EXPIRY=${NEXTCLOUD_BACKUPS_EXPIRY:-0}

## DATABASE
DB_TYPE=${DB_TYPE:-}
DB_HOST=${DB_HOST:-}
DB_PORT=${DB_PORT:-}
DB_NAME=${DB_NAME:-}
DB_USER=${DB_USER:-}
DB_PASS=${DB_PASS:-}

## PHP_FPM
NEXTCLOUD_PHP_FPM_HOST=${NEXTCLOUD_PHP_FPM_HOST:-}
NEXTCLOUD_PHP_FPM_PORT=${NEXTCLOUD_PHP_FPM_PORT:-}
